package com.zjn.zjngraduationdesign.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.zjn.zjngraduationdesign.entity.User;
import com.zjn.zjngraduationdesign.service.UserService;


@Controller
@RequestMapping("/user")
public class UserController {
	@Autowired
	UserService userService;
	
	@RequestMapping("index")
	public String toLogin() {
		
		return "front/index";				
	}
			
	@RequestMapping("login")
	public String login(String username, String password) {
		boolean flag = userService.checkLogin(username, password);
		if(flag) {
			return "front/index";
		}
		return "index";
		
	}
	
	@RequestMapping(value="toregist",method=RequestMethod.GET)
    public String toRegist() {
    	return "front/signup";
    }
	
	@RequestMapping("regist")
	public String register(User user) {
		userService.addUser(user);
//		System.out.println(user.getUsername());
		return "front/signup";
	}
	
	@RequestMapping("flights")
	public String fly() {
		
		return "front/flights";				
	}
	
}
